<html>
<head>
    <meta charset="utf-8">
    <title>志愿填报系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../static/css/layui.css" media="all">
</head>
<style>
    body {
        margin-left: 0px;
        margin-top: 0px;
        margin-right: 0px;
        margin-bottom: 0px;
        overflow: hidden;
    }
</style>
<body class="layui-layout-body">
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<!--导航栏-->
<ul class="layui-nav" lay-filter="nav_main" id="menu">
</ul>

<div class="layui-tab-item layui-show">
    <iframe src="pages/main.html" frameborder="0" id="iframes" style="width: 100%; height: 100%;" name="iframes">
    </iframe>
</div>
<script src="../static/layui.js" charset="utf-8"></script>
<script>
    function clickme() {
        /*先判断里面有没有该样式*/
        if($("#sys").attr("class").indexOf("layui-nav-itemed")>0){
            $("#sys").removeClass("layui-nav-itemed");
        }else{
            $("#sys").addClass("layui-nav-itemed");
        }
    }
    layui.use(['form', 'layedit', 'laydate','element'], function () {

        $ = layui.$;

        $.ajax({
            url: "/menu/list",
            data: ({
                "role": "admin",
            }),
            type: "GET",
            dataType: "json",
            success: function (data) {
                //添加菜单
                for (var i = 0; i < data.length; i++) {
                    /*子级菜单的添加，明天做*/
                    if (data[i].child.length != 0) {
                        $("#menu").append("<li class='layui-nav-item' id='sys' onclick='clickme()'><a href='javascript:;'><span class='layui-nav-more'></span>" + data[i].name + "</a><dl class='layui-nav-child'><dd><a href='um.html' target='iframes'>用户管理</a></dd> </dl></li>");
                    } else {
                        $("#menu").append("<li class='layui-nav-item'><a href='" + data[i].url + "' target='iframes'>" + data[i].name + "</a></li>");
                    }
                }
            },
            error: function (data) {
                console.log("error");
            }
        })

    });
</script>
</body>
</html>